<template>
	<div class="carAndCredit">
		<div class="title">车辆信息</div>
		<div>
			<el-row class="info-row" v-show="isEdit == true">
				<el-col :span="3" class="subTitle">
					产地性质
				</el-col>
				<el-col :span="5">
					<el-select class="info-select" v-model="carInfo.originType" placeholder="请选择">
						<el-option v-for="item in $store.state.carOriginType" :key="item.value" :label="item.label" :value="item.value">
						</el-option>
					</el-select>
				</el-col>
				<el-col :span="3" class="subTitle">
					品牌车型
				</el-col>
				<el-col :span="5">
					<el-autocomplete class="info-select" v-model="carInfo.brand" :fetch-suggestions="querySearchCarModel" placeholder="请输入内容" :trigger-on-focus="false"></el-autocomplete>
				</el-col>
				<el-col :span="3" class="subTitle">
					座位数
				</el-col>
				<el-col :span="5">
					<el-select class="info-select" v-model="carInfo.seating" placeholder="请选择">
						<el-option v-for="item in $store.state.seating" :key="item.value" :label="item.label" :value="item.value">
						</el-option>
					</el-select>
				</el-col>
			</el-row>
			<el-row class="info-row" v-show="isEdit == false">
				<el-col :span="8" class="info-label">
					产地性质：
					<label class="text">{{carInfo.originType_name}}</label>
				</el-col>
				<el-col :span="8" class="info-label">
					品牌车型：
					<label class="text">{{carInfo.brand_name}}</label>
				</el-col>
				<el-col :span="8" class="info-label">
					座位数：
					<label class="text">{{carInfo.seating_name}}</label>
				</el-col>
			</el-row>
			<el-row class="info-row" v-show="isEdit == true">
				<el-col :span="3" class="subTitle">
					车型构成
				</el-col>
				<el-col :span="5">
					<el-select class="info-select" v-model="carInfo.vehicleComposition" placeholder="请选择">
						<el-option v-for="item in $store.state.barVehicleComposition" :key="item.value" :label="item.label" :value="item.value">
						</el-option>
					</el-select>
				</el-col>
				<el-col :span="3" class="subTitle">
					行驶证车主
				</el-col>
				<el-col :span="5">
					<el-input class="info-input" v-model="carInfo.drivingLicensePerson"></el-input>
				</el-col>
				<el-col :span="3" class="subTitle">
					有无续保
				</el-col>
				<el-col :span="5">
					<el-select class="info-select" v-model="carInfo.renewalInsurance" placeholder="请选择">
						<el-option v-for="item in $store.state.carRenewalInsurance" :key="item.value" :label="item.label" :value="item.value">
						</el-option>
					</el-select>
				</el-col>
			</el-row>
			<el-row class="info-row" v-show="isEdit == false">
				<el-col :span="8" class="info-label">
					车型构成：
					<label class="text">{{carInfo.vehicleComposition_name}}</label>
				</el-col>
				<el-col :span="8" class="info-label">
					行驶证车主：
					<label class="text">{{carInfo.drivingLicensePerson}}</label>
				</el-col>
				<el-col :span="8" class="info-label">
					有无续保：
					<label class="text">{{carInfo.renewalInsurance_name}}</label>
				</el-col>
			</el-row>
			<el-row class="info-row" v-show="isEdit == true">
				<el-col :span="3" class="subTitle">
					二手车车龄
				</el-col>
				<el-col :span="5">
					<el-date-picker class="info-input" v-model="carInfo.age" type="date" placeholder="选择日期" :disabled="isCarAge"></el-date-picker>
				</el-col>
				<el-col :span="3" class="subTitle">
					车价
				</el-col>
				<el-col :span="5">
					<el-input class="info-input" v-model="carInfo.price">
						<template slot="append">元</template>
					</el-input>
				</el-col>
				<el-col :span="3" class="subTitle">
					新车指导价
				</el-col>
				<el-col :span="5">
					<el-input class="info-input isOptional" v-model="carInfo.newPrice">
						<template slot="append">元</template>
					</el-input>
				</el-col>
				<label class="subTitleSele">（选填）</label>
			</el-row>
			<el-row class="info-row" v-show="isEdit == false">
				<el-col :span="8" class="info-label">
					二手车车龄：
					<label class="text">{{carInfo.age}}</label>
				</el-col>
				<el-col :span="8" class="info-label">
					车价：
					<label class="text">{{carInfo.price}}元</label>
				</el-col>
				<el-col :span="8" class="info-label">
					新车指导价：
					<label class="text">{{carInfo.newPrice}}元</label>
				</el-col>
			</el-row>
		</div>
		<div class="title">贷款信息</div>
		<div>
			<el-row class="info-row" v-show="isEdit == true">
				<el-col :span="3" class="subTitle">
					贷款银行
				</el-col>
				<el-col :span="5">
					<el-select class="info-select" v-model="creditInfo.bank" placeholder="请选择">
						<el-option v-for="item in $store.state.bank" :key="item.value" :label="item.label" :value="item.value">
						</el-option>
					</el-select>
				</el-col>
				<el-col :span="3" class="subTitle">
					年限
				</el-col>
				<el-col :span="5">
					<el-select class="info-select" v-model="creditInfo.year" placeholder="请选择">
						<el-option v-for="item in $store.state.creditYear" :key="item.value" :label="item.label" :value="item.value">
						</el-option>
					</el-select>
				</el-col>
				<el-col :span="3" class="subTitle">
					开票价
				</el-col>
				<el-col :span="5">
					<el-input class="info-input isOptional" v-model="creditInfo.price">
						<template slot="append">元</template>
					</el-input>
				</el-col>
				<label class="subTitleSele">（选填）</label>
			</el-row>
			<el-row class="info-row" v-show="isEdit == false">
				<el-col :span="8" class="info-label">
					贷款银行：
					<label class="text">{{creditInfo.bank_name}}</label>
				</el-col>
				<el-col :span="8" class="info-label">
					年限：
					<label class="text">{{creditInfo.year_name}}</label>
				</el-col>
				<el-col :span="8" class="info-label">
					开票价：
					<label class="text">{{creditInfo.price}}元</label>
				</el-col>
			</el-row>
			<el-row class="info-row" v-show="isEdit == true">
				<el-col :span="3" class="subTitle">
					客户费率
				</el-col>
				<el-col :span="5">
					<el-input class="info-input" v-model="creditInfo.rate">
						<template slot="append">%</template>
					</el-input>
				</el-col>
				<el-col :span="3" class="subTitle">
					公司费率
				</el-col>
				<el-col :span="5">
					<el-input class="info-input" v-model="creditInfo.doRate">
						<template slot="append">%</template>
					</el-input>
				</el-col>
				<el-col :span="3" class="subTitle">
					贷款额
				</el-col>
				<el-col :span="5">
					<el-input class="info-input" v-model="creditInfo.creditPrice">
						<template slot="append">元</template>
					</el-input>
				</el-col>
			</el-row>
			<el-row class="info-row" v-show="isEdit == false">
				<el-col :span="8" class="info-label">
					客户费率：
					<label class="text">{{creditInfo.rate}}%</label>
				</el-col>
				<el-col :span="8" class="info-label">
					公司费率：
					<label class="text">{{creditInfo.doRate}}%</label>
				</el-col>
				<el-col :span="8" class="info-label">
					贷款额：
					<label class="text">{{creditInfo.creditPrice}}元</label>
				</el-col>
			</el-row>
			<el-row class="info-row" v-show="isEdit == true">
				<el-col :span="3" class="subTitle">
					首付款
				</el-col>
				<el-col :span="5">
					<el-input class="info-input" :disabled="disabled" v-model="creditInfo.firstPrice">
						<template slot="append">元</template>
					</el-input>
				</el-col>
				<el-col :span="3" class="subTitle">
					首付比例
				</el-col>
				<el-col :span="5">
					<el-input class="info-input" :disabled="disabled" v-model="creditInfo.firstRate">
						<template slot="append">%</template>
					</el-input>
				</el-col>
				<el-col :span="3" class="subTitle">
					贷款比例
				</el-col>
				<el-col :span="5">
					<el-input class="info-input" :disabled="disabled" v-model="creditInfo.creditRate">
						<template slot="append">%</template>
					</el-input>
				</el-col>
			</el-row>
			<el-row class="info-row" v-show="isEdit == false">
				<el-col :span="8" class="info-label">
					首付款：
					<label class="text">{{creditInfo.firstPrice}}元</label>
				</el-col>
				<el-col :span="8" class="info-label">
					首付比例：
					<label class="text">{{creditInfo.firstRate}}%</label>
				</el-col>
				<el-col :span="8" class="info-label">
					贷款比例：
					<label class="text">{{creditInfo.creditRate}}%</label>
				</el-col>
			</el-row>
			<el-row class="info-row" v-show="isEdit == true">
				<el-col :span="3" class="subTitle">
					月付款
				</el-col>
				<el-col :span="5">
					<el-input class="info-input" :disabled="disabled" v-model="creditInfo.monthPrice">
						<template slot="append">元</template>
					</el-input>
				</el-col>
				<el-col :span="3" class="subTitle">
					业务类型
				</el-col>
				<el-col :span="5">
					<el-select class="info-select" v-model="creditInfo.type" placeholder="请选择">
						<el-option v-for="item in $store.state.serviceType" :key="item.value" :label="item.label" :value="item.value">
						</el-option>
					</el-select>
				</el-col>
			</el-row>
			<el-row class="info-row" v-show="isEdit == false">
				<el-col :span="8" class="info-label">
					月付款：
					<label class="text">{{creditInfo.monthPrice}}元</label>
				</el-col>
				<el-col :span="8" class="info-label">
					业务类型：
					<label class="text">{{creditInfo.type_name}}</label>
				</el-col>
			</el-row>
		</div>
		<div class="title" v-show="isGps">GPS信息</div>
		<div v-show="isGps">
			<el-row class="info-row" v-show="isEdit == true">
				<el-col :span="3" class="subTitle">
					GPS编号
				</el-col>
				<el-col :span="5">
					<el-input class="info-input" v-model="gpsInfo.code"></el-input>
				</el-col>
				<el-col :span="3" class="subTitle">
					安装位置
				</el-col>
				<el-col :span="5">
					<!-- <el-select class="info-select" v-model="gpsInfo.gpsLocation" placeholder="请选择">
						<el-option v-for="item in $store.state.gpsLocation" :key="item.value" :label="item.label" :value="item.value">
						</el-option>
					</el-select> -->
					<el-input class="info-input" v-model="gpsInfo.gpsLocation"></el-input>
				</el-col>
				<el-col :span="3" class="subTitle">
					gps厂商
				</el-col>
				<el-col :span="5">
					<el-input class="info-input" v-model="gpsInfo.factory"></el-input>
				</el-col>
			</el-row>
			<el-row class="info-row" v-show="isEdit == false">
				<el-col :span="8" class="info-label">
					GPS编号：
					<label class="text">{{gpsInfo.code}}</label>
				</el-col>
				<el-col :span="8" class="info-label">
					安装位置：
					<label class="text">{{gpsInfo.gpsLocation}}</label>
				</el-col>
				<el-col :span="8" class="info-label">
					gps厂商：
					<label class="text">{{gpsInfo.factory}}</label>
				</el-col>
			</el-row>
		</div>
		<div class="title">垫款信息</div>
		<div>
			<el-row class="info-row" v-show="isEdit == true">
				<el-col :span="3" class="subTitle">
					打款单位
				</el-col>
				<el-col :span="5">
					<el-autocomplete class="info-input" :fetch-suggestions="querySearchDealer" v-model="advancesMoneyInfo.unit" @select="dealerSelect" icon="search"></el-autocomplete>
				</el-col>
				<el-col :span="3" class="subTitle">
					开户银行
				</el-col>
				<el-col :span="5">
					<el-input class="info-input" v-model="advancesMoneyInfo.bank"></el-input>
				</el-col>
				<el-col :span="3" class="subTitle">
					开户账号
				</el-col>
				<el-col :span="5">
					<el-input class="info-input" v-model="advancesMoneyInfo.account"></el-input>
				</el-col>
			</el-row>
			<el-row class="info-row" v-show="isEdit == false">
				<el-col :span="8" class="info-label">
					打款单位：
					<label class="text">{{advancesMoneyInfo.unit}}</label>
				</el-col>
				<el-col :span="8" class="info-label">
					开户银行：
					<label class="text">{{advancesMoneyInfo.bank}}</label>
				</el-col>
				<el-col :span="8" class="info-label">
					开户账号：
					<label class="text">{{advancesMoneyInfo.account}}</label>
				</el-col>
			</el-row>
			<el-row class="info-row" v-show="isEdit == true">
				<el-col class="subTitle" :span="3">备注</el-col>
				<el-col :span="21">
					<el-input class="info-textarea" :rows="3" type="textarea" placeholder="请输入" v-model="advancesMoneyInfo.result"></el-input>
				</el-col>
			</el-row>
			<el-row class="info-row resultShrink" v-show="isEdit == false">
				<el-col class="subtitle" :span="3">备　　注</el-col>
				<el-col :span="12" class="text-height text-height-shrink" id='advancesMoneyInfo'>
					{{ advancesMoneyInfo.result }}
				</el-col>
				<el-col :span="3">
					<el-button class="credit-button-text" type="text" @click="$libs.changeHeight('advancesMoneyInfo', advancesMoneyInfo)">{{ advancesMoneyInfo.shrinkText}}</el-button>
				</el-col>
			</el-row>
		</div>
	</div>
</template>
<script>
export default {
	name: 'carAndCredit',
	data() {
		return {
			isEdit: false,
			disabled: true,
			isGps: true, //gps信息是否显示
			id: '',
			otherDate: {},
			isCarAge: false,
			carInfo: {
				originType: '',
				originType_name: '',
				brand: '',
				brand_name: '',
				seating: '',
				seating_name: '',
				vehicleComposition: '',
				vehicleComposition_name: "",
				drivingLicensePerson: '',
				renewalInsurance: '',
				renewalInsurance_name: '',
				age: '',
				price: '',
				newPrice: '',
			},
			creditInfo: {
				bank: '',
				bank_name: '',
				year: '',
				year_name: '',
				price: '',
				rate: '',
				doRate: '',
				creditPrice: '',
				firstPrice: '',
				firstRate: '',
				creditRate: '',
				monthPrice: '',
				type: '',
				type_name: '',
			},
			gpsInfo: {
				code: '',
				gpsLocation: '',
				factory: '',
			},
			advancesMoneyInfo: {
				unit: '',
				bank: '',
				account: '',
				result: '',
				shrink: false,
				shrinkText: '展开全部'
			},
			querySearchDealerCb: ''

		}
	},
	watch: {
		'carInfo.price': function(_cur, _old) {
			this.calculateRate({
				year: this.creditInfo.year,
				price: parseInt(_cur),
				creditPrice: parseInt(this.creditInfo.creditPrice),
				rate: this.creditInfo.rate,
				bank: this.$libs.jsonGetName(this.$store.state.bank, this.creditInfo.bank),
				vehicle: this.carInfo.vehicleComposition
			});
		},
		'creditInfo.year': function(_cur, _old) {
			this.calculateRate({
				year: _cur,
				price: parseInt(this.carInfo.price),
				creditPrice: parseInt(this.creditInfo.creditPrice),
				rate: this.creditInfo.rate,
				bank: this.$libs.jsonGetName(this.$store.state.bank, this.creditInfo.bank),
				vehicle: this.carInfo.vehicleComposition
			});
		},
		'creditInfo.creditPrice': function(_cur, _old) {
			this.calculateRate({
				year: this.creditInfo.year,
				price: parseInt(this.carInfo.price),
				creditPrice: parseInt(_cur),
				rate: this.creditInfo.rate,
				bank: this.$libs.jsonGetName(this.$store.state.bank, this.creditInfo.bank),
				vehicle: this.carInfo.vehicleComposition
			});
		},
		'creditInfo.rate': function(_cur, _old) {
			this.calculateRate({
				year: this.creditInfo.year,
				price: parseInt(this.carInfo.price),
				creditPrice: parseInt(this.creditInfo.creditPrice),
				rate: _cur,
				bank: this.$libs.jsonGetName(this.$store.state.bank, this.creditInfo.bank),
				vehicle: this.carInfo.vehicleComposition
			});
		},
		'creditInfo.bank': function(_cur, _old) {
			this.calculateRate({
				year: this.creditInfo.year,
				price: parseInt(this.carInfo.price),
				creditPrice: parseInt(this.creditInfo.creditPrice),
				rate: this.creditInfo.rate,
				bank: this.$libs.jsonGetName(this.$store.state.bank, _cur),
				vehicle: this.carInfo.vehicleComposition
			});
		},
		'carInfo.vehicleComposition': function(_cur, _old) {
			if (_cur == 0 || _cur == 2) {
				// 新车时不需要二手车车辆
				this.isCarAge = true;
				this.carInfo.age = '';
			} else {
				this.isCarAge = false;
			}
			this.calculateRate({
				year: this.creditInfo.year,
				price: parseInt(this.carInfo.price),
				creditPrice: parseInt(this.creditInfo.creditPrice),
				rate: this.creditInfo.rate,
				vehicle: _cur
			});
		},
		'advancesMoneyInfo.unit': function(_cur, _old) {
			if (_cur) {
				this.querySearchDealer(_cur, this.querySearchDealerCb);
			}
		},
		deep: true
	},
	methods: {
		querySearchCarModel(queryString, cb) {
			// 品牌车型的模糊搜索
			this.$http.get('/carModel/' + queryString).then((data) => {
				if (data.data.success) {
					let carModelArr = [];
					let datas = data.data.data;
					if (datas && datas.length > 0) {
						for (var i = 0; i < datas.length; i++) {
							carModelArr.push({
								value: datas[i].brand + ' ' + datas[i].series,
								address: datas[i].brand + ' ' + datas[i].series,
							});
						}
						cb(carModelArr);
					}
				}
			}).catch((error) => {

			})
		},
		calculateRate(_json) {
			// {
			// 	year:'',//年限
			// 	price:'',//车价
			// 	creditPrice:'',//贷款额
			// 	rate:''//年费率
			// 	bank:''//贷款银行
			// 	vehicle:'',//车型 0-省内新车 1-省内二手车 2-省外新车 3-省外二手车
			// }
			_json.year = parseInt(this.$libs.jsonGetName(this.$store.state.creditYear, _json.year));
			_json.rate = parseInt(_json.rate) / 100;
			console.log(_json.year);
			console.log('_json.bank' + _json.bank);
			if (_json.creditPrice > _json.price) {
				this.$message.error('贷款额不能大于车价');
				return;
			}
			if (_json.price && _json.creditPrice) {
				this.creditInfo.firstPrice = (_json.price - _json.creditPrice).toFixed(2); //首付款
				this.creditInfo.firstRate = (this.creditInfo.firstPrice / _json.price * 100).toFixed(2); //首付比例
				this.creditInfo.creditRate = (this.creditInfo.creditPrice / _json.price * 100).toFixed(2); //贷款比例
			}
			if (_json.year && _json.price && (_json.creditPrice || _json.creditPrice == 0) && (_json.rate || _json.rate == 0) && _json.bank && (_json.vehicle || _json.vehicle == 0)) {
				console.log(_json.creditPrice + '-' + _json.price);
				console.log(_json.creditPrice > _json.price)
				if (_json.bank == '工商银行') {
					if (_json.year == 12) {
						this.creditInfo.monthPrice = (_json.creditPrice + _json.creditPrice * (_json.rate - 0.0358)) * 1.0358 / 12;
					}
					if (_json.year == 24) {
						this.creditInfo.monthPrice = (_json.creditPrice + _json.creditPrice * (_json.rate - 0.065)) * 1.065 / 24;
					}
					if (_json.year >= 36 && _json.vehicle == 128) {
						// 省内新车
						this.creditInfo.monthPrice = (_json.creditPrice + _json.creditPrice * (_json.rate - 0.0874)) * 1.0874 / _json.year;
					} else if (_json.year >= 36) {
						this.creditInfo.monthPrice = (_json.creditPrice + _json.creditPrice * (_json.rate - 0.09215)) * 1.09215 / _json.year;
					}
				} else {
					this.creditInfo.monthPrice = _json.creditPrice * (1 + _json.rate) / _json.year;
				}
				this.creditInfo.monthPrice = this.creditInfo.monthPrice.toFixed(2);
			}
		},
		querySearchDealer(queryString, cb) {
			if (!this.querySearchDealerCb) {
				this.querySearchDealerCb = cb;
			}
			let that = this;
			this.$store.commit('dealer', {
				this: that,
				key: this.advancesMoneyInfo.unit,
				cb: () => {
					if (cb) {
						cb(that.$store.state.dealer);
						that.advancesMoneyInfo.payeeDealerId = that.$libs.jsonGetName(that.$store.state.dealer, queryString);
					}
				}
			});
		},
		dealerSelect(_value) {
			this.$http.get('/dealer/detail/' + _value.label).then((data) => {
				if (data.data.success) {
					this.advancesMoneyInfo.bank = data.data.data.dealerAccountVOS[0].bankName;
					this.advancesMoneyInfo.account = data.data.data.dealerAccountVOS[0].bankCard;
				}
			}).catch((data) => {

			});
		},
		getCarInfo(_id) {
			this.$http.get('/carinfo/' + _id).then((data) => {
				console.log(data);
				if (data.data.success) {
					let datas = data.data.data;
					console.log(datas);
					this.carInfo = {
						originType: this.$libs.toInt(datas.carSpec),
						originType_name: this.$libs.jsonGetName(this.$store.state.carOriginType, datas.carSpec),
						brand: datas.carModel,
						brand_name: datas.carModel,
						seating: this.$libs.toInt(datas.seats),
						seating_name: this.$libs.jsonGetName(this.$store.state.seating, datas.seats),
						vehicleComposition: this.$libs.toInt(datas.isNewCar),
						vehicleComposition_name: this.$libs.jsonGetName(this.$store.state.barVehicleComposition, datas.isNewCar),
						drivingLicensePerson: datas.carOwner,
						renewalInsurance: datas.renewalInsurance,
						renewalInsurance_name: this.$libs.jsonGetName(this.$store.state.carRenewalInsurance, datas.renewalInsurance),
						age: datas.carAge,
						price: datas.dealPrice,
						newPrice: datas.guidePrice,
					}
					if (datas.gpsSetLocation && this.isGps == true) {
						this.isGps = true;
					} else {
						this.isGps = false;
					}
					if (this.isGps) {
						this.gpsInfo = {
							code: datas.gpsNum,
							gpsLocation: datas.gpsSetLocation,
							factory: datas.gpsFactory,
						}
					}
				}
			}).catch((error) => {

			});
		},
		getLoanInfo(_id) {
			this.$http.get('/loaninfo/' + _id).then((data) => {
				console.log(data);
				console.log(data.data.success);
				if (data.data.success) {
					let datas = data.data.data;
					console.log(datas);
					this.creditInfo = {
						bank: this.$libs.toInt(datas.bankId),
						bank_name: this.$libs.jsonGetName(this.$store.state.bank, datas.bankId),
						year: this.$libs.toInt(datas.period),
						year_name: this.$libs.jsonGetName(this.$store.state.creditYear, datas.period),
						price: datas.billingAmount,
						rate: datas.companyChargeRate,
						doRate: datas.executionRate,
						creditPrice: datas.loanAmount,
						firstPrice: datas.downPayment,
						firstRate: datas.downPaymentRate,
						creditRate: datas.loanRate,
						monthPrice: datas.monthlyPayment,
						type: this.$libs.toInt(datas.bizTypeId),
						type_name: this.$libs.jsonGetName(this.$store.state.serviceType, datas.bizTypeId),
						bizTypeId: datas.bizTypeId
					};
					this.advancesMoneyInfo = {
						unit: datas.payeeDealerName,
						payeeDealerId: datas.payeeDealerId,
						bank: datas.payeeBankName,
						account: datas.payeeBankCard,
						payeeBankId: datas.payeeBankId,
						result: datas.remark,
						shrink: false,
						shrinkText: '展开全部'
					}
				}
			}).catch((error) => {

			});
		},
		submitInfo(_id, _isMust, _orderStatus, _cb) {
			let param = {
				"actualLoaningAmount": 0,
				"applyStatus": "void",
				"bankId": this.creditInfo.bank,
				"bankLoanAmount": 0,
				"billingAmount": parseInt(this.creditInfo.price),
				"bizTypeId": 0,
				"bizTypeName": this.creditInfo.type,
				"carId": 0,
				"carLevel": 0,
				"carModel": this.carInfo.brand,
				"carOwner": this.carInfo.drivingLicensePerson,
				"carSpec": this.carInfo.originType,
				"companyChargeRate": parseInt(this.creditInfo.rate),
				"customerId": 0,
				"dealPrice": parseInt(this.carInfo.price),
				"dealerId": "void",
				"dealerName": "void",
				"deptId": 0,
				"deptName": "void",
				"downPayment": parseInt(this.creditInfo.firstPrice),
				"downPaymentRate": parseInt(this.creditInfo.firstRate),
				"engineNum": "void",
				"executionRate": parseInt(this.creditInfo.doRate),
				"guidePrice": this.carInfo.newPrice ? parseInt(this.carInfo.newPrice) : '',
				"handleStaffId": 0,
				"invoiceNum": "void",
				"invoiceVendor": "void",
				"isDeleted": 0,
				"isNewCar": parseInt(this.carInfo.vehicleComposition),
				"licensePlateAddr": "void",
				"licensePlateType": 0,
				"loanAmount": parseInt(this.creditInfo.creditPrice),
				"loanInfoId": 0,
				"loanRate": parseInt(this.creditInfo.creditRate),
				"loanUseage": "void",
				"loaningAmount": 0,
				"monthlyPayment": parseInt(this.creditInfo.monthPrice),
				"orderNo": _id,
				payeeDealerId: this.advancesMoneyInfo.payeeDealerId,
				"payeeDealerName": this.advancesMoneyInfo.unit,
				"payeeBankCard": parseInt(this.advancesMoneyInfo.account),
				"payeeBankName": this.advancesMoneyInfo.bank,
				"paymentWay": 0,
				"period": parseInt(this.creditInfo.year),
				"renewalInsurance": this.carInfo.renewalInsurance,
				"seats": parseInt(this.carInfo.seating),
				remark: this.advancesMoneyInfo.result,
				"staffId": 0,
				"staffName": "void",
				"vinNo": "void"

			};
			console.log(param);
			if (this.isGps) {
				param.gpsFactory = this.gpsInfo.factory;
				param.gpsNum = this.gpsInfo.code;
				param.gpsSetLocation = this.gpsInfo.gpsLocation;
			}
			if (_isMust && !this.$libs.mustWrite(param, ['guidePrice', 'billingAmount', 'remark'])) {
				this.$store.commit('isAllMustFalse');
				if (_cb) {
					_cb();
				}
				this.$libs.noneAddHightBorder();
				return;
			} else if (_isMust) {
				// this.$store.commit('isAllMustTrue');
				console.log('must' + 2);
			}

			$.each(param, (i, val) => {
				if (val == "void") {
					param[i] = '';
				}
			});

			if(typeof this.carInfo.age =='string'){
				param.carAge = this.carInfo.age
			}else{
				param.carAge = this.$libs.formatDate(this.carInfo.age,'yyyy-MM-dd')
			}
			this.$http.post('/loaninfo/', param).then((data) => {
				console.log(data);
				if (data.data.success) {
					this.id = _id;
					this.orderStatus = _orderStatus;
					this.otherDate = {
						bizType: this.creditInfo.type,
						loanMoney: parseInt(this.creditInfo.creditPrice) ? parseInt(this.creditInfo.creditPrice) : 0
					};
					this.$store.commit('saveNumAdd', this);
				} else {
					this.$message.error(data.data.message);
				}
			}).catch((error) => {

			});
		}
	},
	mounted() {
		this.$store.commit('bank', this);
		this.$store.commit('carOriginType', this);
		this.$store.commit('seating', this);
		this.$store.commit('barVehicleComposition', this);
		this.$store.commit('creditYear', this);
		this.$store.commit('serviceType', this);
		this.$store.commit('gpsLocation', this);
		let that = this;
		this.$store.commit('dealer', {
			this: that
		});
	}
}

</script>
<style lang="scss" scoped>
@import '../../assets/css/site.scss';
.carAndCredit {
	font-size: 14px;
	color: #475669;
	padding-top: 17px;
}

</style>
